/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ec.socialfun.controladores;

import com.ec.socialfun.datamanager.CartaClienteDataManager;
import com.ec.socialfun.servicios.LocalesFacade;
import com.ec.socialfun.servicios.ProductosFacade;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.component.UIForm;
import org.jboss.logging.Logger;

/**
 *
 * @author sebas
 */
@ManagedBean
@RequestScoped
public class CartaClienteControlador extends PadreControlador {

    private static final Logger LOG = Logger.getLogger(CartaClienteControlador.class.getName());
    @ManagedProperty(value = "#{cartaClienteDataManager}")
    private CartaClienteDataManager cartaClienteDataManager;
    @EJB
    private ProductosFacade productosFacade;
    @EJB
    private LocalesFacade localesFacade;
    private UIForm FormularioCarta;

    public CartaClienteDataManager getCartaClienteDataManager() {
        return cartaClienteDataManager;
    }

    public void setCartaClienteDataManager(CartaClienteDataManager cartaClienteDataManager) {
        this.cartaClienteDataManager = cartaClienteDataManager;
    }

    public UIForm getFormularioCarta() {
        String parametro = obtenerParametro("id");
        Integer codigo = Integer.parseInt(parametro);
        if (parametro != null) {
            LOG.info("PARAMETRO " + codigo);
            getCartaClienteDataManager().setLocal(localesFacade.recuperarPorCodigo(codigo));
            LOG.info("LOCAL "+getCartaClienteDataManager().getLocal().getLoNombre());
            getCartaClienteDataManager().setListaProdcutos(productosFacade.recuperarCarta(getCartaClienteDataManager().getLocal()));
            mostrarColumnaPrecio();
        }

        return FormularioCarta;
    }

    public void setFormularioCarta(UIForm FormularioCarta) {
        this.FormularioCarta = FormularioCarta;
    }

    public boolean mostrarColumnaPrecio() {
        getCartaClienteDataManager().setMostrarPrecio(true);
        if("NO".equals(getCartaClienteDataManager().getLocal().getLoMostrarPrecio()))
        {
            LOG.info("BOOLEAN MOSTRAR PRECIO");
            getCartaClienteDataManager().setMostrarPrecio(false);
        }
       return getCartaClienteDataManager().isMostrarPrecio();
    }
    

    public CartaClienteControlador() {
    }

    @Override
    public void iniciarDatos() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
